package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaishengit.entity.File;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class FileDao {
	private DBHelp<File> db = new DBHelp<File>();
	public File findById(int id){
		String sql = "select * from t_file where id=?;";
		return db.executeQueryForObject(sql, new FileRowMapper(), id);
	}
	private class FileRowMapper implements RowMapper<File> {

		public File mapperRow(ResultSet rs) throws SQLException {
			// TODO Auto-generated method stub
			File f = new File();
			f.setBuilder(rs.getString("builder"));
			f.setFileName(rs.getString("fileName"));
			f.setId(rs.getInt("id"));
			f.setFolderID(rs.getInt("folderID"));
			f.setSize(rs.getFloat("size"));
			return f;
		}
		
	}
}
